var emptyform = {
    word:'',
    star:1,
    success:false,
    classtime:1,
    sentence:[],
    synonym:[],
    antonym:[],
    phrase:[],
    explanations:[],
    remarks:[]
};
const state ={
    loginusername:'Terminal-user',
    loginuserid:-1,
    avatar:'',
    recordtime:null,
    roles:[],
    everyday:null,
    form1:null
};

const mutations ={
    setForm(state,formdata){
        state.form1 = formdata;
        console.log(state.form1);
    },
    setEveryDay(state,data){
        state.everyday = data;
    },
    resetForm(state){
        emptyform = {
            word:'',
            star:1,
            success:false,
            classtime:1,
            synonym:[],
            antonym:[],
            phrase:[],
            explanations:[],
            sentence:[],
            remarks:[]
        };
        state.form1 = null;
    }
};

const actions = {
    setForm(context,formdata){
        console.log('setform action');
        console.log(formdata);
        context.commit('setForm',formdata);
    },
    resetForm(context){
        context.commit('resetForm');
    },
    setEveryDay(context,data){
        context.commit('setEveryDay',data);
    }
};

const getters = {
    form1:state=>{
        if(!state.form1)
            state.form1 = emptyform;
        return state.form1;
    }
};
export default {
    namespaced:true,
    state,
    mutations,
    actions,
    getters
}